local Startup = {}
Startup.__cname = "Startup"
Startup.__index = Startup
Startup.__ctype = 2
require "pack"
function Startup.new(...)
    local instance = setmetatable({}, Startup)
    instance.class = Startup
    instance:ctor(...)
    return instance
end
function Startup:ctor(appName, packageRoot)
    self.name = appName
    self.packageRoot = packageRoot or appName
end
function Startup:run()
	local sharedFileUtils = cc.FileUtils:getInstance()
    local cached_res = "cached_res/";
    local downloadPath =   sharedFileUtils:getWritablePath()
    downloadPath=downloadPath..cached_res
	local pkgPath      = "res/"
	print(string.format("downloadPath: %s  pkgPath: %s", downloadPath, pkgPath))
	DOWNLOAD_PATH = downloadPath
    sharedFileUtils:addSearchPath(downloadPath)
    if  cc.Application:getInstance():getTargetPlatform() == 4 or 
        cc.Application:getInstance():getTargetPlatform() == 5 then
        local l = string.pack("l", 0xFFFFFFFFFFFF)
        if #l >= 8 then
            sharedFileUtils:addSearchPath("cached_res64/")
            sharedFileUtils:addSearchPath("res64/")
        end
        --device.platform
    elseif cc.Application:getInstance():getTargetPlatform() ==0 then
        sharedFileUtils:addSearchPath(cached_res.."/image")
    end
    sharedFileUtils:addSearchPath(cached_res)
    sharedFileUtils:addSearchPath(pkgPath)
	require("script.update.UpdateApp").new("update"):run(true)
end
return Startup

